Package es.csic.iiia.fabregues.dip
Class Observer
java.lang.Object
es.csic.iiia.fabregues.dip.Observer
- Direct Known Subclasses:
Player
public abstract class Observer
extends java.lang.Object
Observer of the game. It cannot play.
- Author:
- Angela Fabregues, IIIA-CSIC, fabregues@iiia.csic.es
-
Field Summary
Fields Modifier and Type Field Description protected Comm
comm
protected Game
game
es.csic.iiia.fabregues.utilities.Interface
log
java.lang.String
logPath
protected java.lang.String
mapName
protected java.lang.String
name
protected int
pressLevel
protected java.lang.String
version
java.lang.String
winner
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description abstract void
afterOldPhase()
Deprecated.use phaseEnd insteadabstract void
beforeNewPhase()
does something when the phase startsvoid
exit()
ends the gameint
getBuildTimeLimit()
Returns the deadline for build phases (WIN) in milliseconds.Game
getGame()
int
getMoveTimeLimit()
Returns the deadline for move phases (SPR and FAL) in milliseconds.java.lang.String
getName()
int
getRetreatTimeLimit()
Returns the deadline for retreat phases (SUM and AUT) in milliseconds.java.lang.String
getVersion()
void
handleCCD(java.lang.String string)
void
handleServerOFF()
ends the game when the server is offvoid
handleSlo(java.lang.String winner)
ends the game when someone has won.void
handleSMR(java.lang.String[] message)
abstract void
init()
does something before the game has startedvoid
mapConfirmation()
void
phaseEnd(GameState gameState)
Does something when the phase ends and before a new one startsabstract void
receivedOrder(Order order)
does something with every received last phase written ordervoid
setGame(Game game)
void
setMap(java.lang.String map)
saves the name of the map.void
start(IComm comm)
Observer startvoid
start(IComm comm, boolean enableLogging)
void
start(IComm commImpl, es.csic.iiia.fabregues.utilities.Interface log)
Observer start reusing log file
-
Field Details
-
comm
-
game
-
mapName
protected java.lang.String mapName -
name
protected java.lang.String name -
version
protected java.lang.String version -
pressLevel
protected int pressLevel -
log
public es.csic.iiia.fabregues.utilities.Interface log -
logPath
public java.lang.String logPath -
winner
public java.lang.String winner
-
-
Constructor Details
-
Method Details
-
start
- Throws:
CommException
-
start
Observer start- Parameters:
ip
-port
-name
-- Throws:
java.io.IOException
CommException
CommException
-
start
public void start(IComm commImpl, es.csic.iiia.fabregues.utilities.Interface log) throws CommExceptionObserver start reusing log file- Parameters:
ip
- of the serverport
- of the servername
- of the observerlog
- file- Throws:
CommException
java.io.IOException
CommException
-
setMap
saves the name of the map. If the map is the standard, it builds the game. Otherwise, it requests a map definition, MDF.- Parameters:
map
-- Throws:
CommException
-
handleSlo
public void handleSlo(java.lang.String winner)ends the game when someone has won.- Parameters:
winner
-
-
handleServerOFF
public void handleServerOFF()ends the game when the server is off -
exit
public void exit()ends the game -
mapConfirmation
- Throws:
CommException
-
init
public abstract void init()does something before the game has started -
receivedOrder
does something with every received last phase written order -
afterOldPhase
public abstract void afterOldPhase()Deprecated.use phaseEnd insteadDoes something when the phase ends and before a new one starts -
beforeNewPhase
does something when the phase starts- Throws:
CommException
-
setGame
-
getGame
-
getName
public java.lang.String getName() -
getVersion
public java.lang.String getVersion() -
getMoveTimeLimit
public int getMoveTimeLimit()Returns the deadline for move phases (SPR and FAL) in milliseconds. -
getRetreatTimeLimit
public int getRetreatTimeLimit()Returns the deadline for retreat phases (SUM and AUT) in milliseconds. -
getBuildTimeLimit
public int getBuildTimeLimit()Returns the deadline for build phases (WIN) in milliseconds. -
handleSMR
public void handleSMR(java.lang.String[] message) -
phaseEnd
Does something when the phase ends and before a new one starts- Parameters:
gameState
-
-
handleCCD
public void handleCCD(java.lang.String string)
-